Skip to content

Implement Mixed Mode State Detection#1396

Merged
heypnus merged 1 commit into
vmware-tanzu:mainfrom
heypnus:m1
Jun 30, 2026
Merged

Implement Mixed Mode State Detection#1396
heypnus merged 1 commit into
vmware-tanzu:mainfrom
heypnus:m1

Conversation

@heypnus

@heypnus heypnus commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

This patch introduces the Mixed Mode state detection logic for NSX Operator
to determine the network scope (T1, VPC, or VDS) it operates within. This
is critical for deciding which controllers should be activated.

Key features:

  • Introduced an informer for the NetworkSettings CR in the Controller
    Runtime cache to efficiently determine the global network state.
  • Added detection logic for VDS alongside T1 and VPC based on the
    NetworkSettings provider field.
  • Implemented capability checking by reading the
    supports_per_namespace_network_provider key from the status.supervisor
    path in the SupervisorCapabilities CR.
  • Incorporated the EnableVPCNetwork configuration override to act as an
    early trigger. This solves the "chicken-and-egg" problem by allowing
    VPC-specific controllers to start before the NetworkSettings CRs are
    updated to provider: vpc.
  • Re-enabled the enable_vpc_network config override check in mixed mode
    initialization and state refresh, which acts as an early trigger for
    VPC-specific controllers.

After this change, the NSX-Operator will start VPC controllers as long as
enable_vpc_network is true. And the T1 controllers will be started when:
(supports_per_namespace_network_provider is activated) AND (at least one NetworkingSettings CR has provider=="nsx-tier1")
OR
(supports_per_namespace_network_provider is deactivated) AND (enable_vpc_network is false)

Testing done:

  1. T1 pipeline with ID 5771
  2. VPC pipeline with ID 19252

@codecov-commenter

codecov-commenter commented Mar 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.20814% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.11%. Comparing base (128342c) to head (b35d166).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
pkg/config/mixed_mode.go 77.00% 44 Missing and 2 partials ⚠️
cmd/main.go 0.00% 11 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1396      +/-   ##
==========================================
+ Coverage   77.96%   78.11%   +0.15%     
==========================================
  Files         184      187       +3     
  Lines       24907    25446     +539     
==========================================
+ Hits        19419    19878     +459     
- Misses       4179     4249      +70     
- Partials     1309     1319      +10     
Flag Coverage Δ
unit-tests 78.11% <74.20%> (+0.15%) ⬆️
Files with missing lines Coverage Δ
pkg/nsx/client.go 93.16% <ø> (-0.49%) ⬇️
pkg/nsx/services/securitypolicy/parse.go 94.11% <100.00%> (ø)
pkg/nsx/util/license.go 100.00% <100.00%> (ø)
cmd/main.go 0.00% <0.00%> (ø)
pkg/config/mixed_mode.go 77.00% <77.00%> (ø)

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@heypnus heypnus force-pushed the m1 branch 3 times, most recently from 0fea7b3 to c0064c0 Compare March 30, 2026 17:20
Comment thread pkg/config/mixed_mode.go Outdated
Comment thread pkg/config/mixed_mode.go Outdated
Comment thread pkg/config/mixed_mode.go Outdated
Comment thread pkg/config/mixed_mode.go Outdated
Comment thread pkg/config/mixed_mode.go Outdated
Comment thread pkg/config/mixed_mode.go Outdated
Comment thread pkg/config/mixed_mode.go
Comment thread pkg/nsx/util/license.go Outdated
Comment thread pkg/nsx/util/license_test.go
Comment thread pkg/nsx/services/securitypolicy/parse.go
@heypnus heypnus force-pushed the m1 branch 2 times, most recently from 0f8b260 to 5af4a3f Compare April 13, 2026 06:22
@heypnus heypnus force-pushed the m1 branch 4 times, most recently from 6e1cc2d to c0b5bbb Compare April 14, 2026 09:00
@heypnus heypnus requested a review from yanjunz97 April 14, 2026 09:03
Comment thread pkg/config/mixed_mode.go
Comment thread pkg/config/mixed_mode.go Outdated
@heypnus heypnus force-pushed the m1 branch 2 times, most recently from 0858f1b to 40a6a6a Compare May 9, 2026 09:01
@heypnus heypnus requested a review from yanjunz97 May 9, 2026 09:28
@heypnus

heypnus commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

/e2e

yanjunz97
yanjunz97 previously approved these changes May 14, 2026

@yanjunz97 yanjunz97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@heypnus

heypnus commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

/e2e

Comment thread pkg/config/mixed_mode.go
Comment thread pkg/config/mixed_mode.go
@heypnus

heypnus commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

/e2e

@heypnus heypnus force-pushed the m1 branch 2 times, most recently from 7c9bd2a to 43f7269 Compare June 23, 2026 08:54
@heypnus

heypnus commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

/e2e

@heypnus heypnus force-pushed the m1 branch 3 times, most recently from 2a560f4 to d81c765 Compare June 29, 2026 04:52
Comment thread pkg/config/mixed_mode.go Outdated
@heypnus heypnus force-pushed the m1 branch 2 times, most recently from 468f567 to 4d2b6ca Compare June 29, 2026 07:59
@heypnus

heypnus commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

/e2e

This patch introduces the Mixed Mode state detection logic for NSX Operator
to determine the network scope (T1, VPC, or VDS) it operates within. This
is critical for deciding which controllers should be activated.

Key features:
- Introduced an informer for the NetworkSettings CR in the Controller
  Runtime cache to efficiently determine the global network state.
- Added detection logic for VDS alongside T1 and VPC based on the
  NetworkSettings `provider` field.
- Implemented capability checking by reading the
  `supports_per_namespace_network_provider` key from the `status.supervisor`
  path in the Capabilities CR.
- Incorporated the `EnableVPCNetwork` configuration override to act as an
  early trigger. This solves the "chicken-and-egg" problem by allowing
  VPC-specific controllers to start before the NetworkSettings CRs are
  updated to `provider: vpc`.
- Wrapped all corresponding controller capability gates to strictly use
  the global `config.HasVPCNamespaces()` and `config.HasT1Namespaces()`
  checks.

After this change, the NSX-Operator will start VPC controllers as long as
enable_vpc_network is true. And the T1 controllers will be started when:
  (supports_per_namespace_network_provider is activated) AND (at least one NetworkingSettings CR has provider=="nsx-tier1")
OR
  (supports_per_namespace_network_provider is deactivated) AND (enable_vpc_network is false)

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread pkg/config/mixed_mode.go
@heypnus heypnus merged commit 535498a into vmware-tanzu:main Jun 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants